import axios from './request'

const fetch = (method, url, parmas) => {
  if (method === 'get') {
    let strUrl = url + '?'
    for (let key in parmas) {
      strUrl += key + '=' + parmas[key] + '&'
    }
    strUrl = strUrl.substring(0, strUrl.length - 1)
    // console.log(strUrl)
    return axios({
      method: method,
      url: strUrl
    })
  } else if (method === 'post') {
    return axios({
      method: method,
      url: url,
      data: parmas
    })
  } else if (method === 'delete') {
    return axios({
      method: method,
      url: url,
      data: parmas
    })
  }
}

const urlDev = "/dingdingdemo"
const urlOnline = "/zpdsctool"
let baseUrl = process.env.NODE_ENV === 'development' ?  urlDev : urlOnline

// get
export const openLogin = (data) => fetch('get', baseUrl + '/VirDesigner/login', data)

// post
export const openLogin2 = (data) => fetch('post', baseUrl + '/VirDesigner/login', data)



